package edu.uclm.esi.tysw.tusEntradas.persistence;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Conexion {
	private Connection bd;
	protected String url="jdbc:mysql://localhost:3306/misentradas";
	private int id; 

	public Conexion(int id) throws SQLException {
		this.id=id;
		this.bd=DriverManager.getConnection(url, "root", "root1234");
	}
	
	public Conexion(int id, String user, String pwd) throws SQLException {
		this.id=id;
		this.bd=DriverManager.getConnection(url, user, pwd);
	}

	public void close() {
		try {
			this.bd.close();
		}
		catch (Exception e) {
		}
	}

	public int getId() {
		return id;
	}

	public PreparedStatement prepareStatement(String sql) throws SQLException {
		return this.bd.prepareStatement(sql);
	}

	public CallableStatement prepareCall(String call) throws SQLException {
		return this.bd.prepareCall(call);
	}
}
